package com.mall.biz.eshop;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.eshop.TransferAuditService;
import com.mall.pojo.TransferAudit;
import com.mall.pojo.TransferAuditExample;
import com.mall.pojo.TransferAuditExample.Criteria;
import com.mall.query.eshop.TransferAuditQuery;

@Service
/**
 * 转账审核
 * @author Administrator
 *
 */
public class TransferAuditBizImpl {
	@Autowired
	private TransferAuditService transferAuditService;
	
	
	public List<TransferAudit> getTransferAuditListByQuery(TransferAuditQuery transferAuditQuery){
		TransferAuditExample transferAuditExample = getTransferAuditExampleByQuery(transferAuditQuery);
		return this.transferAuditService.getTransferAuditListByExample(transferAuditExample);
	}
	
	public int getTransferAuditCountByQuery(TransferAuditQuery transferAuditQuery){
		TransferAuditExample transferAuditExample = getTransferAuditExampleByQuery(transferAuditQuery);
		return this.transferAuditService.getTransferAuditCount(transferAuditExample);
	}
	
	
	
	private TransferAuditExample getTransferAuditExampleByQuery(TransferAuditQuery transferAuditQuery){
		TransferAuditExample transferAuditExample = new TransferAuditExample();
		if(transferAuditQuery.getPage() != null){
			transferAuditExample.setStart(transferAuditQuery.getPage().getBegin());
			transferAuditExample.setLimit(transferAuditQuery.getPage().getLength());
		}
		transferAuditExample.setOrderByClause(transferAuditQuery.getOrderBy());
		
		Criteria criteria = transferAuditExample.createCriteria();
		
		if(transferAuditQuery.getMallId() != null && transferAuditQuery.getMallId() > 0){
			criteria.andMallIdEqualTo(transferAuditQuery.getMallId());
		}
		if(transferAuditQuery.getOnlyKey() != null){
			criteria.andCommOnlyKeyEqualTo(transferAuditQuery.getOnlyKey());
		}
		if(transferAuditQuery.getPhone() != null){
			criteria.andPhoneEqualTo(transferAuditQuery.getPhone());
		}
		if(transferAuditQuery.getStatus() != null){
			criteria.andStatusEqualTo(transferAuditQuery.getStatus());
		}
		if(transferAuditQuery.getType() != null){
			criteria.andTypeEqualTo(transferAuditQuery.getType());
		}
		if(transferAuditQuery.getUserId() != null){
			criteria.andUserIdEqualTo(transferAuditQuery.getUserId());
		}
		
		return transferAuditExample;
	}
}
